// 抽离可公用的格式化数据
import { h } from "vue";

export function usePublicFormats() {
  //支付状态
  const statusOptions = [
    {
      value: -1,
      label: "请选择"
    },
    {
      value: 0,
      label: "停用"
    },
    {
      value: 1,
      label: "启用"
    }
  ];

  const orderStatusOptions = [
    {
      value: -1,
      label: "请选择"
    },
    {
      value: 0,
      label: "预约中"
    },
    {
      value: 1,
      label: "进行中"
    },
    {
      value: 1,
      label: "已结束"
    }
  ];

  //车辆类型
  const carTypeOptions = [
    {
      value: -1,
      label: "请选择"
    },
    {
      value: 1,
      label: "小型车"
    },
    {
      value: 2,
      label: "中型车"
    },
    {
      value: 3,
      label: "大型车"
    },
    {
      value: 4,
      label: "其他"
    }
  ];

  //车牌颜色
  const carColorOptions = [
    {
      value: -1,
      label: "请选择"
    },
    {
      value: 1,
      label: "蓝牌"
    },
    {
      value: 3,
      label: "黄牌"
    },
    {
      value: 6,
      label: "绿牌"
    },
    {
      value: 7,
      label: "白牌"
    },
    {
      value: 8,
      label: "黑牌"
    }
  ];

  //支付方式
  const paymentMethodOptions = [
    {
      value: -1,
      label: "请选择"
    },
    {
      value: 1,
      label: "全额支付"
    },
    {
      value: 2,
      label: "部分支付"
    }
  ];

  //订单类型
  const orderTypeOptions = [
    {
      value: -1,
      label: "请选择"
    },
    {
      value: 1,
      label: "小强停车"
    },
    {
      value: 2,
      label: "泊安飞"
    },
    {
      value: 3,
      label: "钉钉"
    },
    {
      value: 0,
      label: "如之停车"
    }
  ];

  //超停配置
  const abnormalOptions = [
    {
      value: -1,
      label: "请选择"
    },
    {
      value: 0,
      label: "正常"
    },
    {
      value: 1,
      label: "超停"
    }
  ];

  const parkListOptions = [
    {
      value: -1,
      label: "请选择"
    },
    {
      value: 110106300134,
      label: "北京南站立体停车场"
    },
    {
      value: "110106300191",
      label: "丰台站站前P2停车场"
    }
  ];

  //车牌颜色反显
  function carColorShow(color) {
    let color_show;
    switch (color) {
      case 1:
        color_show = "蓝牌";
        break;
      case 3:
        color_show = "黄牌";
        break;
      case 6:
        color_show = "绿牌";
        break;
      case 7:
        color_show = "白牌";
        break;
      case 8:
        color_show = "黑牌";
        break;
      default:
        color_show = "未知";
        break;
    }
    return h("span", { style: { color_show } }, color_show);
  }

  //支付方式反显
  function paymentMethodShow(payment_method) {
    let payment_method_return: string;
    switch (payment_method) {
      case 1:
        payment_method_return = "全额支付";
        break;
      case 2:
        payment_method_return = "部分支付";
        break;
    }
    return h(
      "span",
      { style: { payment_method_return } },
      payment_method_return
    );
  }

  //订单类型反显
  function orderTypeShow(orderType) {
    let orderTypeShow;
    switch (orderType) {
      case 1:
        orderTypeShow = "小强停车";
        break;
      case 2:
        orderTypeShow = "泊安飞";
        break;
      default:
        orderTypeShow = "如之停车";
        break;
    }
    return h("span", { style: { orderTypeShow } }, orderTypeShow);
  }

  function carTypeShow(carType) {
    let carTypeShow;
    switch (carType) {
      case 1:
        carTypeShow = "小型车";
        break;
      case 2:
        carTypeShow = "中型车";
        break;
      case 3:
        carTypeShow = "大型车";
        break;
      case 4:
        carTypeShow = "其他";
        break;
    }
    return h("span", { style: { carTypeShow } }, carTypeShow);
  }

  function orderStatusShow(orderStatus) {
    let orderStatusShow;
    switch (orderStatus) {
      case 0:
        orderStatusShow = "预约中";
        break;
      case 1:
        orderStatusShow = "进行中";
        break;
      case 2:
        orderStatusShow = "已结束";
        break;
    }
    return h("span", { style: { orderStatusShow } }, orderStatusShow);
  }

  //超停反显
  function abnormalShow(abnormal) {
    let abnormalShow;
    switch (abnormal) {
      case 0:
        abnormalShow = "正常";
        break;
      case 1:
        abnormalShow = "超停";
        break;
    }
    return h("span", { style: { abnormalShow } }, abnormalShow);
  }

  function parkListShow(parkCode) {
    let parkCodeShow;
    switch (parkCode) {
      case 110101300023:
        parkCodeShow = "北京站停车场（地下）";
        break;
      case 110106300134:
        parkCodeShow = "北京南站立体停车场";
        break;
      case 110106300191:
        parkCodeShow = "丰台站站前P2停车场";
        break;
    }

    return h("span", { style: { parkCodeShow } }, parkCodeShow);
  }

  return {
    statusOptions,
    carTypeOptions,
    carColorOptions,
    paymentMethodOptions,
    orderTypeOptions,
    orderStatusOptions,
    abnormalOptions,
    parkListOptions,

    carColorShow,
    orderTypeShow,
    paymentMethodShow,
    carTypeShow,
    orderStatusShow,
    abnormalShow,
    parkListShow
  };
}
